package com.wanxi.dangdang.controller.front.scenic;

import com.github.pagehelper.PageInfo;
import com.wanxi.dangdang.common.CommonResult;
import com.wanxi.dangdang.model.vo.PageScenicDimVO;
import com.wanxi.dangdang.model.vo.ScenicFindByIdVO;
import com.wanxi.dangdang.model.vo.ScenicPageVO;
import com.wanxi.dangdang.service.ScenicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: yanguangqiong
 * @Description:
 * @Date: Created in 2021/9/10
 * @Version: 1.0
 */
@RestController
@RequestMapping("/front/c/science")
@Api(tags = "C端页面景区")
@Slf4j
public class CScenicController {
    @Autowired
    private ScenicService scenicService;

    @ApiOperation("C端用户通过景区id查看景区信息")
    @GetMapping("/findById")
    public CommonResult<ScenicFindByIdVO> findById(@ApiParam("景区Id") @RequestParam Long id) {
        log.info("景区id为：{}",id);
        if (id.equals("")){
            return CommonResult.validateFailed();
        }
        ScenicFindByIdVO scenic = scenicService.findById(id);
        return CommonResult.successData(scenic);
    }

    @ApiOperation("C端用户访问分销商分页查询找到所有景区信息，包括模糊查询")
    @GetMapping("/findPage") //C端用户传入分销商id 地区 景区标题
    public CommonResult<PageInfo<ScenicPageVO>> findPage(PageScenicDimVO pageScenicDimVO, Integer pageNum, Integer pageSize) {
            log.info("页数为：{}",pageNum,"每页为：{}",pageSize);
        if (pageNum.equals("") || pageSize.equals("")){
            return CommonResult.validateFailed();
        }
        PageInfo<ScenicPageVO> pageInfo = scenicService.findPage(pageScenicDimVO, pageNum, pageSize);
        return CommonResult.successData(pageInfo);
    }
}
